<template>
  <div class="wrap hot">
    <div class="header">
      <p class="title">
        <img src="../assets/img/hot.png" alt="" />
        <span>热门兑换</span>
      </p>
      <p class="more">
        <span>更多</span>
        <img src="../assets/img/arrow.png" alt="" />
      </p>
    </div>
    <div class="banner">
      <img src="../assets/img/banner.4c6b6225.png" alt="" />
    </div>
    <ul class="items">
      <li v-for="item in arr" :key="item.id" @click="toDetails(item.id)">
        <div class="img-box">
          <img :src="'http://sc.wolfcode.cn' + item.coverImg" alt="" />
        </div>
        <div class="txt">
          <h2>{{ item.title }}</h2>
          <p>
            {{ item.coin }}
            <img src="../assets/img/monad.png" alt="" />
          </p>
          <span>立即兑换</span>
        </div>
        <img
          src="../assets/img/section_hot.png"
          v-show="item.isHotSale"
          alt=""
          class="label"
        />
        <img
          src="../assets/img/section_new.png"
          v-show="item.isLatest"
          alt=""
          class="label"
        />
      </li>
    </ul>
  </div>
</template>

<script>
// 记得引入API的时候要{} 因为导出的时候是export不是export default
import { hotAPI } from "../request/api";
export default {
  data() {
    return {
      arr: [],
    };
  },
  async created() {
    let res = await hotAPI();
    console.log("22222", res);
    this.arr = res.data.data.records;
  },

  mounted() {},

  methods: {
    toDetails(id) {
      this.$router.push(`/details?id=${id}`);
    },
  },
};
</script>

<style lang="less" scoped>
.hot {
  padding-bottom: 50px;
  .header {
    padding: 30px 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    .title {
      img {
        width: 34px;
        height: 38px;
      }
      span {
        width: 119px;
        height: 29px;
        line-height: 29px;
        font-size: 30px;
        font-family: SourceHanSansSC;
        font-weight: bold;
        color: #242b39;
        line-height: 23px;
        padding-left: 10px;
      }
    }
    .more {
      cursor: pointer;
      span {
        padding-right: 6px;
        vertical-align: middle;
      }
      img {
        width: 14px;
        height: 14px;
        vertical-align: middle;
      }
    }
  }

  .banner {
    width: 100%;
  }

  .items {
    display: flex;
    justify-content: space-between;
    padding-top: 30px;
    flex-wrap: wrap;
    li {
      position: relative;
      width: 285px;
      height: 412px;
      transition: 1s;
      padding-top: 30px;
      cursor: pointer;
      .label {
        position: absolute;
        top: 30px;
        left: 0;
      }
      .img-box {
        width: 285px;
        height: 250px;
        img {
          width: 285px;
          height: 250px;
        }
      }
      .txt {
        width: 285px;
        height: 162px;
        background: #ffffff;
        font-size: 18px;
        font-family: SourceHanSansSC;
        display: flex;
        flex-wrap: wrap;
        justify-content: space-around;
        text-align: center;
        h2 {
          height: 30px;
          line-height: 30px;
          width: 100%;
          font-weight: 300;
          color: #333333;
          line-height: 23px;
          padding: 20px;
          box-sizing: border-box;
        }
        p {
          width: 100%;
          height: 18px;
          line-height: 18px;
          font-weight: bold;
          color: #fd604d;
          line-height: 23px;
          img {
            width: 20px;
            vertical-align: middle;
          }
        }
        span {
          width: 100px;
          height: 36px;
          border: 1px solid #0a328e;
          line-height: 36px;
          color: #0a328e;
        }
      }
    }
  }
  .items li:hover {
    .txt span {
      background-color: #0a328e;
      color: #ffffff;
    }
    transform: translateY(-20px);
    box-shadow: 0 5px 10px 1px rgb(229, 226, 226);
  }
}
</style>